import Vue from 'vue';
import VueRouter from 'vue-router';
import Login from '../views/Login.vue';
import Home from '../views/Home.vue';
import Welcome from '../views/Welcome.vue';
import DormAdminManager from '../views/DormAdminManager.vue';
import DormAdminAddOrEdit from "../views/DormAdminAddOrEdit";
import StudentsManager from "../views/StudentsManager";
import StudentsAddOrEdit from "../views/StudentsAddOrEdit";
import DormsManager from "../views/DormsManager";
import DormsAddOrEdit from "../views/DormsAddOrEdit";
import AbsencesManager from "../views/AbsencesManager";
import AbsencesAddOrEdit from "../views/AbsencesAddOrEdit";
import ModifyPassword from "../views/ModifyPassword";

Vue.use(VueRouter);

const routes = [
  {
    path: '/', //默认路径
    name: 'Login',
    component: Login
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: '/welcome.html',
    children: [
      { path: '/welcome.html', name: 'Welcome', component: Welcome },
      {
        path: '/dormAdminManager.html',
        name: 'DormAdminManager',
        component: DormAdminManager
      },
      {
        path: '/dormAdminManager/toAdd.html',
        name: 'DormAdminAddOrEdit',
        component: DormAdminAddOrEdit
      },
      {
        path: '/dormAdminManager/toEdit/:id.html',
        name: 'DormAdminAddOrEdit',
        component: DormAdminAddOrEdit
      },

      {
        path: '/students.html',
        name: 'StudentsManager',
        component: StudentsManager
      },
      {
        path: '/students/toAdd.html',
        name: 'StudentsAddOrEdit',
        component: StudentsAddOrEdit
      },
      {
        path: '/students/toEdit/:id.html',
        name: 'StudentsAddOrEdit',
        component: StudentsAddOrEdit
      },

      {
        path: '/dorms.html',
        name: 'DormsManager',
        component: DormsManager
      },
      {
        path: '/dorms/toAdd.html',
        name: 'DormsAddOrEdit',
        component: DormsAddOrEdit
      },
      {
        path: '/dorms/toEdit/:id.html',
        name: 'DormsAddOrEdit',
        component: DormsAddOrEdit
      },

      {
        path: '/absences.html',
        name: 'AbsencesManager',
        component: AbsencesManager
      },
      {
        path: '/absences/toAdd.html',
        name: 'AbsencesAddOrEdit',
        component: AbsencesAddOrEdit
      },
      {
        path: '/absences/toEdit/:id.html',
        name: 'AbsencesAddOrEdit',
        component: AbsencesAddOrEdit
      },

      {
        path: '/modifyPassword.html',
        name: 'ModifyPassword',
        component: ModifyPassword
      }
    ]
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
];

const router = new VueRouter({
  routes
});

export default router;
